<!DOCTYPE html>

<html>

	<head>

		<meta charset="utf-8" />

		<title>排期设置</title>

		<meta name="keywords" content="" />

		<meta name="description" content="" />

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />

		<meta name="format-detection" content="telephone=no" />

		<meta name="apple-mobile-web-app-capable" content="yes" />

		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		

		<link rel="stylesheet" href="__TMPL__/public/assets1/css/mui.min.css" />

		<link rel="stylesheet" href="__TMPL__/public/assets1/css/style.css" />

		<script type="text/javascript" src="__TMPL__/public/assets1/js/jquery.1.9.1.js" ></script>

		<script type="text/javascript" src="__TMPL__/public/assets1/js/rem.js" ></script>

		

		<script>

			window.onload = function() { 

				$(".load").removeClass("load"); 



			}; 



		</script>

		

		<link rel="stylesheet" type="text/css" href="__TMPL__/public/assets1/css/mui.picker.min.css" />

	</head>

	<body>

		<!--加载遮罩-->

		<div class="load"></div>

		

		<div class="index">

			<div class="title">

				<a href="../index/index" class="t-back mui-icon mui-icon-back"></a>

				<h2>排期设置</h2>

			</div>

			<div class="t-zw"></div>

			

			<div class="det-m">

				<div class="dm-a">

					活动日期设置：<input type="text"  placeholder="theday" id="date" value="theday" class="date" data-options='{"type":"date"}'/>

				</div>

				

				<div class="dm-b">



					<input type="hidden" name="id" id="id" value="{$names.id}">

					{$name}： <input type="text" placeholder="请选择年级" id="grade" value="一年级" /><input type="hidden" id="gradee" value="1" />

				</div>

				

				<div class="dm-box">

					<div class="db-left">

						<ul>

							<li class="on" value="1" >1班</li>

							<li value="2">2班</li>

							<li value="3">3班</li>

							<li value="4">4班</li>

							<li value="5">5班</li>

							<li value="6">6班</li>

							<li value="7">7班</li>

							<li value="8">8班</li>

							<li value="9">9班</li>

							<li value="10">10班</li>

							<li value="11">11班</li>

							<li value="12">12班</li>

							<li value="13">13班</li>

							<li value="14">14班</li>

							<li value="15">15班</li>
							<li value="16">16班</li>

							<li value="17">17班</li>

							<li value="18">18班</li>

							<li value="19">19班</li>

							<li value="20">20班</li>

							<li value="21">21班</li>

							<li value="22">22班</li>

							<li value="23">23班</li>

							<li value="24">24班</li>

							<li value="25">25班</li>

							<li value="26">26班</li>

							<li value="27">27班</li>

							<li value="28">28班</li>

							<li value="29">29班</li>
							<li value="30">30班</li>
						</ul>

					</div>

					<div class="db-right">

						<div class="dr-m dr-0" style="display: block;">

							<div class="dr-a" id="cc">

								<p class="dr-p1">课程表</p>

								<ul id='ul'>

									

								</ul>

							</div>

							<div class="dr-b">

								<p class="dr-p1">课程名称</p>

								<ul>

									<foreach name="lessons" item="lessons">
									<li>{$lessons.title}</li>
									</foreach>

								</ul>

							</div>

						</div>

					</div>

					<div class="clear"></div>

				</div>

			</div>

			

			<div class="det-zw"></div>

			<div class="det-btn"><button type="button" id="ff">提交排期</button></div>

		</div>

		

		<script type="text/javascript" src="__TMPL__/public/assets1/js/mui.min.js" ></script>

		<script type="text/javascript" src="__TMPL__/public/assets1/js/public.js" ></script>

		<script type="text/javascript" src="__TMPL__/public/assets1/js/doT.js" ></script>

		<script type="text/x-dot-template" id="data_1">

			[[?it.lessonNames == '']]

				<li>

					<span>9:00-9:40</span>

					<select name="" id="my_level-name">

						<option value="0">请选择课程</option>

						

							[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>9:45-10:25</span>

					<select name="" id="my_level-name1">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>10:30-11:05</span>

					<select name="" id="my_level-name2">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>13:30-14:10</span>

					<select name="" id="my_level-name3">

						<option value="0">请选择课程</option>

						

							[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>14:15-15:05</span>

					<select name="" id="my_level-name4">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>15:05-16:00</span>

					<select name="" id="my_level-name5">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>16:05-16:45</span>

					<select name="" id="my_level-name6">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>16:50-17:30</span>

					<select name="" id="my_level-name7">

						<option value="0">请选择课程</option>

						

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNamea]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

							[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>
				<input type="hidden" id="ids" value="2">
			[[??]]
				<input type="hidden" id="ids" value="1">
				<li>

					<span>9:00-9:40</span>
						
						<input type="hidden" id="id0" value="[[=it.lessonNames[0].lesson_id]]">

					<select name="" id="my_level-names">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[0].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>9:45-10:25</span>

						<input type="hidden" id="id1" value="[[=it.lessonNames[1].lesson_id]]">

					<select name="" id="my_level-names1">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[1].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>10:30-11:05</span>

						<input type="hidden" id="id2" value="[[=it.lessonNames[2].lesson_id]]">

					<select name="" id="my_level-names2">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[2].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>13:30-14:10</span>

						<input type="hidden" id="id3" value="[[=it.lessonNames[3].lesson_id]]">

					<select name="" id="my_level-names3">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[3].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>14:15-15:05</span>

						<input type="hidden" id="id4" value="[[=it.lessonNames[4].lesson_id]]">

					<select name="" id="my_level-names4">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[4].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>15:05-16:00</span>

						<input type="hidden" id="id5" value="[[=it.lessonNames[5].lesson_id]]">

					<select name="" id="my_level-names5">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[5].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>16:05-16:45</span>

						<input type="hidden" id="id6" value="[[=it.lessonNames[6].lesson_id]]">

					<select name="" id="my_level-names6">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[6].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

				<li>

					<span>16:50-17:30</span>

						<input type="hidden" id="id7" value="[[=it.lessonNames[7].lesson_id]]">

					<select name="" id="my_level-names7">

						<option value="0">请选择课程</option>

						[[~it.lessons:val:key]]

							[[?val.name_id == it.lessonNames[7].name_id]]

								<option value="[[=val.name_id]]" selected>[[=val.title]]</option>

							[[??]]

								<option value="[[=val.name_id]]">[[=val.title]]</option>

							[[?]]

						[[~]]

					</select>

					<button type="button" class="mui-icon mui-icon-closeempty"></button>

				</li>

			[[?]]

		</script>



		<!--日期选择-->

		<script src="__TMPL__/public/assets1/js/mui.picker.min.js"></script>
		

		<script type="text/javascript">

			$(function(){

					$("#ff").click(function() {
						
						if ($('#ids').val() == 1) {
						var formData = new FormData

						var options=$('#my_level-names option:selected'); 

						var ssid=options.text(); //拿到选中项的值

						var ssids=options.val();
				
						 formData.append('ssid',ssid);

						 formData.append('ssids',ssids);

						var options=$('#my_level-names1 option:selected'); 

						var ssid1=options.text(); //拿到选中项的值

						var ssids1=options.val();
					
						 formData.append('ssid1',ssid1);

						 formData.append('ssids1',ssids1);

						var options=$('#my_level-names2 option:selected'); 

						var ssid2=options.text(); //拿到选中项的值

						var ssids2=options.val();

						 formData.append('ssid2',ssid2);

						 formData.append('ssids2',ssids2);

						var options=$('#my_level-names3 option:selected'); 

						var ssid3=options.text(); //拿到选中项的值

						var ssids3=options.val();

						 formData.append('ssid3',ssid3);

						  formData.append('ssids3',ssids3);

						var options=$('#my_level-names4 option:selected'); 

						var ssid4=options.text(); //拿到选中项的值

						var ssids4=options.val();

						 formData.append('ssid4',ssid4);

						 formData.append('ssids4',ssids4);

						var options=$('#my_level-names5 option:selected'); 

						var ssid5=options.text(); //拿到选中项的值

						var ssids5=options.val();

						 formData.append('ssid5',ssid5);

						 formData.append('ssids5',ssids5);

						var options=$('#my_level-names6 option:selected'); 

						var ssid6=options.text(); //拿到选中项的值

						var ssids6=options.val();

						 formData.append('ssid6',ssid6);

						 formData.append('ssids6',ssids6);

						var options=$('#my_level-names7 option:selected'); 

						var ssid7=options.text(); //拿到选中项的值

						var ssids7=options.val();
						
						 formData.append('ssid7',ssid7);

						 formData.append('ssids7',ssids7);

					  var leid = $('#id0').val();

					   var leid1 = $('#id1').val();

					    var leid2 = $('#id2').val();

					     var leid3 = $('#id3').val();

					      var leid4 = $('#id4').val();

					       var leid5 = $('#id5').val();

					        var leid6 = $('#id6').val();

					         var leid7 = $('#id7').val();

					          formData.append('leid',leid);

					           formData.append('leid1',leid1);

					            formData.append('leid2',leid2);

					             formData.append('leid3',leid3);

					              formData.append('leid4',leid4);

					               formData.append('leid5',leid5);

					                formData.append('leid6',leid6);

					                 formData.append('leid7',leid7);

						$.ajax({

							type: "POST",

							url:"{:url('index/page')}",
						
							data: formData,

							dataType:'JSON',
                			async:'true',  
						  	
                			cache: false,

							processData: false,  
							contentType: false,

							success: function(data) {

								if (data.code == 1) {							
							 	alert(data.msg);

							 	 // $("#ul").html();

							 	  get();

							}else{
							 	 
							 	 alert(data.msg);

							 	get();

							 	 //location.reload();							 								 
							 }

							}

						});
						
					}else{
							var formData = new FormData

						var ban = $('.db-left .on').val();
					
	    				var id = $('#id').val();

						var date = $('#date').val();

						var grade = $('#gradee').val();

						
				 	formData.append('id',id);

				 	formData.append('date',date);

				 	formData.append('grade',grade);

				 	formData.append('ban',ban);

						var options=$('#my_level-name option:selected'); 

						var ssid=options.text(); //拿到选中项的值

						var ssids=options.val();
					
						 formData.append('ssid',ssid);

						 formData.append('ssids',ssids);

						var options=$('#my_level-name1 option:selected'); 

						var ssid1=options.text(); //拿到选中项的值

						var ssids1=options.val();
					
						 formData.append('ssid1',ssid1);

						 formData.append('ssids1',ssids1);

						var options=$('#my_level-name2 option:selected'); 

						var ssid2=options.text(); //拿到选中项的值

						var ssids2=options.val();

						 formData.append('ssid2',ssid2);

						 formData.append('ssids2',ssids2);

						var options=$('#my_level-name3 option:selected'); 

						var ssid3=options.text(); //拿到选中项的值

						var ssids3=options.val();

						 formData.append('ssid3',ssid3);

						  formData.append('ssids3',ssids3);

						var options=$('#my_level-name4 option:selected'); 

						var ssid4=options.text(); //拿到选中项的值

						var ssids4=options.val();

						 formData.append('ssid4',ssid4);

						 formData.append('ssids4',ssids4);

						var options=$('#my_level-name5 option:selected'); 

						var ssid5=options.text(); //拿到选中项的值

						var ssids5=options.val();

						 formData.append('ssid5',ssid5);

						 formData.append('ssids5',ssids5);

						var options=$('#my_level-name6 option:selected'); 

						var ssid6=options.text(); //拿到选中项的值

						var ssids6=options.val();

						 formData.append('ssid6',ssid6);

						 formData.append('ssids6',ssids6);

						var options=$('#my_level-name7 option:selected'); 

						var ssid7=options.text(); //拿到选中项的值

						var ssids7=options.val();
						
						 formData.append('ssid7',ssid7);

						 formData.append('ssids7',ssids7);
											
					 
						$.ajax({

							type: "POST",

							url:"{:url('index/pages')}",
						
							data: formData,
							dataType:'JSON',
                			async:'true',  						  	
                			cache: false,

							processData: false,  
							contentType: false,

							success: function(data) {

								if (data.code == 1) {								
							 	alert(data.msg);
						
						 	  get();

							}else{
							 	
							 	 alert(data.msg);

							 	get();
									 
							 }

							}

						});
						
					}
				})
			 })

		</script>



		<script type="text/javascript">

			function get(){

					var formData = new FormData

					var ban = $('.db-left .on').val();
				
    				var id = $('#id').val();

					var date = $('#date').val();

					var grade = $('#gradee').val();
			
				 	formData.append('id',id);

				 	formData.append('date',date);

				 	formData.append('grade',grade);

				 	formData.append('ban',ban);

					$.ajax({
						type: "POST",
						url:"{:url('index/sousou')}",
						data:formData,
						dataType: 'JSON',
						cache: false,  
						processData: false,  
						contentType: false,
						success: function(data) {

							//alert(data.code);

							if (data.code == 1) {

								var Text = doT.template($('#data_1').text())

	           					 mui("#ul")[0].innerHTML = Text(data.data);

								console.log(data.data);
								ges();

							}
												
						}
					})
			}

		</script>

		

		<script>

			(function($) {

				$.init();

				var result = $('.date')[0];

				var btns = $('.date');

				btns.each(function(i, btn) {

					btn.addEventListener('tap', function() {

						var _self = this;

						if(_self.picker) {

							_self.picker.show(function (rs) {

								result.innerText = '选择结果: ' + rs.text;

								_self.picker.dispose();

								_self.picker = null;

							});

						} else {

							var optionsJson = this.getAttribute('data-options') || '{}';

							var options = JSON.parse(optionsJson);

							var id = this.getAttribute('id');

							/*

							 * 首次显示时实例化组件

							 * 示例为了简洁，将 options 放在了按钮的 dom 上

							 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker

							 */

							_self.picker = new $.DtPicker(options);

							_self.picker.show(function(rs) {

								result.value = rs.text;

								/* 

								 * 返回 false 可以阻止选择框的关闭

								 * return false;

								 */

								/*

								 * 释放组件资源，释放后将将不能再操作组件

								 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。

								 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。

								 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。

								 */

								_self.picker.dispose();

								_self.picker = null;

								get();

							});

						}

						

					}, false);

				});

			})(mui);

		</script>

		

		<!--年级选择-->

		<script>

			(function($, doc) {

				$.init();

				$.ready(function() {

					/**

					 * 获取对象属性的值

					 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；

					 * @param {Object} obj 对象

					 * @param {String} param 属性名

					 */

					var _getParam = function(obj, param) {

						return obj[param] || '';

					};

					//普通示例

					var userPicker = new $.PopPicker();

					userPicker.setData([{

						value: '1',

						text: '一年级'

					}, {

						value: '2',

						text: '二年级'

					}, {

						value: '3',

						text: '三年级'

					}, {

						value: '4',

						text: '四年级'

					}, {

						value: '5',

						text: '五年级'

					}, {

						value: '6',

						text: '六年级'

					}, {

						value: '7',

						text: '七年级'

					}, {

						value: '8',

						text: '八年级'

					}, {

						value: '9',

						text: '九年级'

					}
					]);

					var showUserPickerButton = doc.getElementById('grade');

					var grade = doc.getElementById('grade');

					showUserPickerButton.addEventListener('tap', function(event) {

						userPicker.show(function(items) {

							grade.value = items[0].text;

							gradee.value = items[0].value;

							//返回 false 可以阻止选择框的关闭userResult

							//return false;

							get();

						});

					}, false);

				});

			})(mui, document);

		</script>

		

		<!--课程选择-->

		<script>

			function ges(){

			$(".dr-a ul li select").change(function(){

				if($(this).val() != 0){

					$(this).siblings("button").show();

				}else{

					$(this).siblings("button").hide();

				}

			})

			$(".dr-a ul li button").click(function(){

				$(this).hide();

				$(this).siblings("select").val(0);

			})

			}

		</script>

		<!-- 获取当天日期 -->

		<script type="text/javascript">

			var t=new Date();



			var y=t.getFullYear();



			var m=t.getMonth()+1;



			if(m<10){



			m="0"+m;



			}



			var d=t.getDate();



			var theday=y+"-"+m+"-"+d;



			var theday = $('#date').val(theday);

			 get();

		</script>

		<!-- 班级选择 -->

		<script type="text/javascript">



			$(".db-left ul li").click(function(){

	  			$(".db-left ul li").removeClass("on");

	  			$(this).addClass("on");

	  			get();

			});

		</script>

	</body>

</html>

